package WaiBao;

import java.util.Arrays;

public class FengYaXing {
    public static void main(String[] args) {
        String[] name = {"王志刚(班长)", "李小乐(副班长)", "小李(学习委员)", "张大伟(团支书)", "温馨", "李颖", "冯马志浩", "王明菊", "李小村", "曹永红", "罗奔波", "层滋味",
                "西施", "许文燕", "赵丽艳", "王昭君", "易小花", "宋永健", "王晓丽", "杨凌", "李静瑶", "李小春", "李静瑶", "周志玲", "夏燕", "冯淑清", "谭建春", "向玉兰",
                "貂蝉", "冯雅鑫(学生)"};//考生本人: 冯雅鑫(学生)
        int[] age = {21, 18, 20, 18, 21, 18, 19, 20, 20, 19, 18, 20, 21, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20,18, 20,21,18, 20};//考生本人年龄:20


        double[] xile1 = {74, 64, 86, 91, 91, 77, 78, 85, 81, 71, 71, 87, 86, 79, 65, 74, 84, 90, 86, 88, 92, 91, 75, 65, 75, 74, 92, 84, 80, 96};
        double[] xile2 = {84, 75, 75, 75, 85, 68, 80, 64, 78, 84, 91, 77, 78, 84, 84, 65, 76, 69, 76, 68, 72, 71, 96, 86, 74, 84, 87, 85, 70, 96};
        double[] xile3 = {69, 61, 84, 85, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 65, 66, 96, 93, 62, 81, 65, 65, 76, 84, 75, 71, 84, 96};


        double banjiu1 ;//代表每个学生的总分
        double banjiu2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            banjiu1  = xile1[i] +xile2[i] + xile3[i];
//            banjiu2 = (banjiu1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + banjiu1);
//            System.out.println(name[i] + "的平均分为:" + banjiu2);
//        }

        double yunlong1 = 0,yunlong2 = 0;
        double[] acer = new double[30];
//        for (int i = 0; i < 30; i++) {
//            yunlong1= xile1[i] + xile2[i] + xile3[i];
//            yunlong2 = (yunlong1* 1.0) / 3;
//            acer[i] = yunlong2;
//        }
//
//        for (int i = 0; i <acer.length - 1; i++) {
//            for (int j = 0; j <acer.length - i - 1; j++) {
//                if (acer[j] <acer[j + 1]) {
//                    double tep = acer[j];
//                    acer[j] = acer[j + 1];
//                    acer[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(acer[i]);
//        }


        double zhijing1 = 0, zhijing2 = 0,zhijing3 = 0;//计算每门课的平均分
        double leshi1 = 0, leshi2 = 0, leshi3 = 0;//计算每门课标准差
        double chaxian1 = 0, chaxian2 = 0,chaxian3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < xile1.length; i++) {
            he +=xile1[i];
        }
        zhijing1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + zhijing1);
        double Sum = 0;
        for (int i = 0; i < xile2.length; i++) {
            Sum +=xile2[i];
        }
        zhijing2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + zhijing2);
        double sum = 0;
        for (int i = 0; i <xile3.length; i++) {
            sum +=xile3[i];
        }
        zhijing3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + zhijing3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <xile1.length; i++) {
            c1 += (xile1[i] -zhijing1) * (xile1[i] - zhijing1);
        }
        leshi1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + leshi1);
        for (int i = 0; i < xile2.length; i++) {
            c2 += (xile2[i] -zhijing2) * (xile2[i] -zhijing2);
        }
        leshi2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +leshi2);

        for (int i = 0; i <xile3.length; i++) {
            c3 += (xile3[i] -zhijing3) * (xile3[i] - zhijing3);
        }
        leshi3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + leshi3);
//////////////
        Arrays.sort(xile1);
        Arrays.sort(xile2);
        Arrays.sort(xile3);
        chaxian1 = (xile1[15] +xile2[14]) * 1.0 / 2;
        chaxian2 = (xile2[15] +xile2[14]) * 1.0 / 2;
        chaxian3 = (xile3[15] +xile3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + chaxian1);
        System.out.println("农业设施设计与制造的中位数为:" + chaxian2);
        System.out.println("园艺植物设施栽培学的中位数为:" + chaxian3);




    }
}
